package com.sx.pipeline.view.treeview2;


/**
 * Created by HQOCSHheqing on 2016/8/2.
 *
 * @description 部门类（继承Node），此处的泛型Integer是因为ID和parentID都为int
 * ，如果为String传入泛型String即可
 */
public class OrganizeDeptRes extends Node<Integer> {
    private Integer userUnitId; //融云用户id
    private String avatar; //头像
    private String userName;//节点显示值
    private Integer pid = null;
    private Integer deptId = null;
    private String deptName;//部门名称
    public OrganizeDeptRes() {
    }

    public OrganizeDeptRes(Integer pid, Integer deptId, String deptName, Integer userUnitId, String userName, String avatar) {
        this.pid = pid;
        this.deptId = deptId;
        this.deptName = deptName;
        this.userUnitId = userUnitId;
        this.userName = userName;
        this.avatar = avatar;

    }

    /**
     * 此处返回节点ID
     *
     * @return
     */
    @Override
    public Integer get_id() {
        if (deptName != null) {
            return deptId;
        } else {
            return userUnitId;
        }
    }

    @Override
    public String get_avator() {
        return avatar;
    }

    @Override
    public Integer get_type() {
        if (deptName!=null){
            return 1;
        }else {
            return 2;
        }
    }

    /**
     * 此处返回父亲节点ID
     *
     * @return
     */
    @Override
    public Integer get_parentId() {
        return pid;
    }

    @Override
    public String get_label() {
        if (deptName != null) {
            return deptName;
        } else {
            return userName;
        }
    }

    @Override
    public boolean parent(Node dest) {
        if (deptId != null) {
            if (deptId == ((Integer) dest.get_parentId()).intValue()) {
                return true;
            }
        }
        if (userUnitId != null) {
            if (userUnitId == ((Integer) dest.get_parentId()).intValue()) {
                return true;
            }
        }

        return false;
    }

    @Override
    public boolean child(Node dest) {
        if (pid == ((Integer) dest.get_id()).intValue()) {
            return true;
        }
        return false;
    }


    public Integer getUserUnitId() {
        return userUnitId;
    }

    public void setUserUnitId(Integer userUnitId) {
        this.userUnitId = userUnitId;
    }

    public String getAvatar() {
        return avatar;
    }

    public void setAvatar(String avatar) {
        this.avatar = avatar;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public Integer getPid() {
        return pid;
    }

    public void setPid(Integer pid) {
        this.pid = pid;
    }

    public Integer getDeptId() {
        return deptId;
    }

    public void setDeptId(Integer deptId) {
        this.deptId = deptId;
    }

    public String getDeptName() {
        return deptName;
    }

    public void setDeptName(String deptName) {
        this.deptName = deptName;
    }


}
